<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta charset="utf-8">
	<title>恒铸智能柜管理平台</title>
	<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
			<meta name="viewport"
				content="width=device-width, initial-scale=1, maximum-scale=1">
				<meta name="apple-mobile-web-app-status-bar-style" content="black">
					<meta name="apple-mobile-web-app-capable" content="yes">
						<meta name="format-detection" content="telephone=no">
							<link rel="stylesheet"
								href="${pageContext.request.contextPath}/resources/layui/css/layui.css"
								media="all" />
							<script type="text/javascript"
								src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
							<script type="text/javascript"
								src="${pageContext.request.contextPath}/resources/js/adminList.js"></script>
							<script type="text/javascript"
								src="${pageContext.request.contextPath}/resources/js/cacheUserInfo.js"></script>
							<script type="text/javascript"
								src="${pageContext.request.contextPath}/resources/js/jquery-1.4.4.min.js"></script>
							
</head>
<style type="text/css">
.layui-form-item .layui-input-inline {
	width: 200px !important;
}

.layui-nav-child {
	border: 1px solid #e6e6e6 !important;
}

.layui-nav-child-child {
	border: 1px solid #e6e6e6 !important;
}

.sumbit {
	margin-left: 120px;
}

a {
	color: #000000 !important;
}

ul li {
	background-color: white;
}

ul li a {
	padding: 0 !important;
}

span {
	color: #000000;
	line-height: 40px;
	text-align: center;
	display: block;
}

.layui-form-item .layui-input-inline {
	width: 200px !important;
}

.layui-nav-child {
	z-index: 999;
}

.layui-nav {
	background-color: #fff;
}

.layui-nav-child {
	display: none !important;
	position: relative;
}

.layui-nav-child-child {
	display: none;
	position: relative;
}

.layui-nav-tree {
	width: 100%;
}

.layui-nav-item:hover .layui-nav-child {
	display: block !important;
	text-align: center;
}

.layui-nav-item:hover {
	display: block;
	color: white;
}

.layui-nav-child-child {
	position: relative;
	left: 100%;
	top: -41px;
}

.li2 {
	height: 40px;
}

.li2:hover {
	background-color: #5FB878;
}

.li2:hover span {
	color: white !important;
}

.li2:hover .layui-nav-child-child {
	display: block;
}

.li3:hover {
	background-color: #5FB878;
}

.li3:hover a {
	color: white !important;
}
</style>

<body class="childrenBody">
	<div style="margin: 10px 0px">
		<blockquote class="layui-elem-quote">
			说明：新建管理员默认密码为:hengzhu123</blockquote>
	</div>
	<div class="layui-form-mid layui-word-aux" style="margin-left: 100px;">
		<g style="color: red!important;padding:5px;">*</g>
		为必填选项
	</div>
	<form class="layui-form" style="position: relative;">

		<div class="layui-form-item">
			<label class="layui-form-label">登录账号</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input loginName" id="loginName"
					name="loginName" style="ime-mode: disabled;"
					lay-verify="required|loginName|number" placeholder="登录账号">
			</div>
			<div class="layui-form-mid layui-word-aux" id="msg">*英文，数字或_,6位以上</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">真实姓名</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input realName" name="realName"
					placeholder="真实姓名">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">手机号码</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input mobilePhone"
					name="mobilePhone" placeholder="请输入手机号码">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">邮箱</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input email" name="email"
					placeholder="请输入邮箱" class="layui-input adminEmail">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司角色:</label>
			<div class="layui-input-inline">
				<select name="compId" lay-filter="selectComp">
					<option value="-1">请选择公司</option>
					 <c:forEach items="${McompList}" var="comp">
						<option value="${comp.value}">${comp.text}</option>
					</c:forEach> 
				</select>
			</div>
			<div class="layui-input-inline">
				<select name="roleId" class="roleId" lay-verify="required">
					<option value="">请选择角色</option>
				</select>
			</div>
			<div class="layui-form-mid layui-word-aux">*</div>
		</div>
		<div class="layui-form-item sumbit" style="top: 300px;">
			<a class="layui-btn" lay-submit lay-filter="addFormAdd" type="sumbit">立即提交</a>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</form>
</body>

</html>
<script type="text/javascript">
        layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function () {
            var form = layui.form,
                layer = parent.layer === undefined ? layui.layer : top.layer,
                $ = layui.jquery,
                laydate = layui.laydate,
                laytpl = layui.laytpl,
                table = layui.table;
			form.render();
            var list = ${McompList};

            form.on("select(selectComp)", function (data) {
                id = data.value;

                $(".roleId option").remove();
                var html='';
                for (var i = 0; i < list.length ; i++) {
                    if(id == list[i].value){
                        for (var j = 0; j < list[i].children.length ; j++) {
                            html += '<option value="'+list[i].children[j].value+'">'+list[i].children[j].text+'</option>';
                        }
                    }else if(id == -1){
                        html = '<option value="">请选择角色</option>';
                    }
                }

                $(".roleId").append(html);
                form.render();
            })

            $("#loginName").keyup(function () {
                var paramstr = $("#loginName").val();
                // console.debug(paramstr);
                $.get("/main/checkName", {loginName: paramstr}, function (res) {
                    if (paramstr.length < 5) {
                        $("#msg").html("<font color='red'>用户名小于5位不可用 </font>");
                    } else {
                        if (!res) {
                            $("#msg").html("<font color='red'>用户名重复 </font>");
                        } else {
                            $("#msg").html("<font color='green'>用户名可用 </font>");
                        }
                    }
                })
            });

            //添加操作
            form.on('submit(addFormAdd)', function (data) {
                $.post("/main/userAdd", data.field, function (rest) {
                    if (rest.success) {
                        layer.msg("添加成功");
                        parent.window.location.reload();
                    } else {
                        layer.msg(rest.message);
                    }
                })
            })
        })
    </script>